const Mock = require('mockjs')
const titles = require('./mock')

const { list, tab } = Mock.mock({
  "list|100": [{
    "id": "@id",
    "image": "@image(200x200, @color)",
    "title": "@ctitle(20, 40)",
    "price|10-1000": 1
  }],
  "tab|25": [{
    "id": "@id",
    "leftTitle|+1": titles,
    "children|5-10": [{
      "title": "@ctitle",
      "children|9": [{
        "image": "@image(100x100, @color)",
        "title": "@ctitle"
      }]
    }]
  }]
})

module.exports = app => {
  app.get('/api/list', (req, res) => {
    res.send({
      code: 200,
      data: list
    })
  })

  app.get('/api/tab', (req, res) => {
    res.send({
      code: 200,
      data: tab
    })
  })
}